public class Text2 {
    public static void main(String[] args) {
        Student student = new Student();
//        student.age = 10;
//        System.out.println(student.age);  //打印age为10
//        student.print();
//        System.out.println(Student.classRoom);
//        student.setSex("男");
//        System.out.println(student.getSex());
//        System.out.println(Student.classRoom);
    }
}
class Student{
    public String name;
    public int age;
    private String sex;  // 封装
    public  static String classRoom;  //静态成员变量
    public void print(){  // 成员方法
        this.age = 10;
        System.out.println(this.age);
    }
    //构造方法
    public Student(){    //构造方法
//        this.print();
        this.name = "小明";  //构造方法大于成员方法的访问
        System.out.println(this.name);
    }

    public String getSex() {
        return sex;  //获取sex的值
    }   //配对private只能在本类中使用

    public void setSex(String sex) {
        this.sex = sex;  // 修改sex的值
    }
//静态代码块用static来修饰
    static{
        classRoom = "109";
        System.out.println("静态代码块");
    }
    //实例代码块
    {
        this.age = 20;
        this.name = "das";
        System.out.println("实例代码块");
        System.out.println(this.name);
        System.out.println(this.age);
    }
}